package com.loooooo.pm2024.data;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.loooooo.pm2024.config.BigIDListSerialize;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class BaseSelector<T> {
    private T target;
    private Integer pageNo;
    private Integer pageSize;
    private String orderBy;

    private String keyword;
    private String startWith;
    private String endWith;

    private Long createdBefore;
    private Long createdAfter;

    private Long now;
    private Integer mine;
    @JsonSerialize(using = BigIDListSerialize.class)
    private List<Long> idList;


    private List<Integer> statusList;
    private Integer withAll;
    private Integer withPrettyActor;

    @JsonSerialize(using = BigIDListSerialize.class)
    private List<Long> idNotList;

    private List<Integer> errorCodeList;
    private List<Integer> excludedErrorCodeList;
    private List<Integer> statusNotList;
    private Long designerAssignedBefore;
    private Long designerAssignedAfter;


    private List<String> groupByList;

    private List<String> havingList;


    private List<Field> fieldList;
    private List<String> columnList;

    public static class Field implements Serializable {
        private String name;
        private String alias;

        public Field() {
        }

        public Field(String name, String alias) {
            this.name = name;
            this.alias = alias;
        }

        public Field(String name ) {
            this.name = name;
            this.alias = name;
        }
        public String getName() {
            return name;
        }

        public Field setName(String name) {
            this.name = name;
            if (!StringUtils.hasText(alias)) alias = name;
            return this;
        }

        public String getAlias() {
            if (!StringUtils.hasText(alias)) alias = name;
            return alias;
        }

        public Field setAlias(String alias) {
            this.alias = alias;
            return this;
        }
    }

    public List<String> getGroupByList() {
        return groupByList;
    }

    public void setGroupByList(List<String> groupByList) {
        this.groupByList = groupByList;
    }

    public List<String> getHavingList() {
        return havingList;
    }

    public void setHavingList(List<String> havingList) {
        this.havingList = havingList;
    }

    public List<Field> getFieldList() {
        return fieldList;
    }

    public List<Field> fieldList() {
        if (fieldList == null) fieldList = new ArrayList<>();
        return fieldList;
    }

    public void setFieldList(List<Field> fieldList) {
        this.fieldList = fieldList;
    }

    public List<String> getColumnList() {
        return columnList;
    }

    public void setColumnList(List<String> columnList) {
        this.columnList = columnList;
    }

    public List<Integer> getErrorCodeList() {
        return errorCodeList;
    }

    public void setErrorCodeList(List<Integer> errorCodeList) {
        this.errorCodeList = errorCodeList;
    }

    public List<Integer> getExcludedErrorCodeList() {
        return excludedErrorCodeList;
    }

    public void setExcludedErrorCodeList(List<Integer> excludedErrorCodeList) {
        this.excludedErrorCodeList = excludedErrorCodeList;
    }

    public List<Long> getIdNotList() {
        return idNotList;
    }

    public void setIdNotList(List<Long> idNotList) {
        this.idNotList = idNotList;
    }

    public List<Integer> getStatusNotList() {
        return statusNotList;
    }

    public void setStatusNotList(List<Integer> statusNotList) {
        this.statusNotList = statusNotList;
    }

    public Long getCreatedBefore() {
        return createdBefore;
    }

    public void setCreatedBefore(Long createdBefore) {
        this.createdBefore = createdBefore;
    }

    public Long getCreatedAfter() {
        return createdAfter;
    }

    public void setCreatedAfter(Long createdAfter) {
        this.createdAfter = createdAfter;
    }

    public BaseSelector() {
    }

    public BaseSelector(T obj) {
        target = obj;
    }

    public T getTarget() {
        return target;
    }

    public BaseSelector<T> setTarget(T target) {
        this.target = target;
        return this;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public List<Long> getIdList() {
        return idList;
    }

    public void setIdList(List<Long> idList) {
        this.idList = idList;
    }

    public Integer getWithAll() {
        return withAll;
    }

    public void setWithAll(Integer withAll) {
        this.withAll = withAll;
    }

    public List<Integer> getStatusList() {
        return statusList;
    }

    public void setStatusList(List<Integer> statusList) {
        this.statusList = statusList;
    }

    public Long getDesignerAssignedBefore() {
        return designerAssignedBefore;
    }

    public void setDesignerAssignedBefore(Long designerAssignedBefore) {
        this.designerAssignedBefore = designerAssignedBefore;
    }

    public Long getDesignerAssignedAfter() {
        return designerAssignedAfter;
    }

    public void setDesignerAssignedAfter(Long designerAssignedAfter) {
        this.designerAssignedAfter = designerAssignedAfter;
    }

    public String getStartWith() {
        return startWith;
    }

    public void setStartWith(String startWith) {
        this.startWith = startWith;
    }

    public String getEndWith() {
        return endWith;
    }

    public void setEndWith(String endWith) {
        this.endWith = endWith;
    }

    public Integer getWithPrettyActor() {
        return withPrettyActor;
    }

    public void setWithPrettyActor(Integer withPrettyActor) {
        this.withPrettyActor = withPrettyActor;
    }

    public Long getNow() {
        return now;
    }

    public void setNow(Long now) {
        this.now = now;
    }

    public Integer getMine() {
        return mine;
    }

    public void setMine(Integer mine) {
        this.mine = mine;
    }
}
